package com.ytc.controller;

import com.ytc.mapper.BookhistoryMapper;
import com.ytc.model.User;
import com.ytc.service.BookhistoryService;
import com.ytc.service.BookshelfService;
import com.ytc.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 详细介绍类情况.
 *
 * @ClassName BookshelfController
 * @Author zk
 * @Date 2023/1/13
 * @Version 1.0
 */
@Controller
@RequestMapping("/bookshelf")
public class BookshelfController {

    @Autowired
    private BookshelfService bookshelfService;

    /**
     * 加入书架
     * @return
     */
    @RequestMapping("addShelf")
    @ResponseBody
    public String addShelf(Integer blId, HttpServletRequest request){
        User user = UserUtil.getUser(request);
        if(user!=null){//用户登录了
            //加入书架
            bookshelfService.addShelf(user.getUId(),blId);
            return "1";//加入书架成功
        }else {
            return "2";
        }
    }
}
